home *** CD-ROM | disk | FTP | other *** search
/ Workbench Designer 2 / Workbench Designer 2.iso / workbench-tools / finderv3 / source / finderv3.c < prev    next >
Encoding:
Text File  |  1997-06-21  |  13.2 KB  |  207 lines

  1. /**************************
  2. **
  3. ** $Id:  Finder.c
  4. ** $VER: Finder.c V3.00r2 (22.06.97) by Chris Jones
  5. **
  6. ** File Finder Utility with wildcards.
  7. ** Based on Amiga Shopper Tutorial by Toby Simpson.
  8. **
  9. ** Creation Date: 17.01.96
  10. ** Revision History:
  11. **                2.00 : (17.01.96) Initial version (beta release)
  12. **                2.01 : (18.01.96) Added AppMenu support
  13. **                                   (Public Release #1 - AUI May '96)
  14. **                2.02 : (04.02.96) Added option to start program
  15. **                                   iconified via tooltype.
  16. **                                   (Beta Release)
  17. **                2.03 : (04.04.96) Added 'Busy Pointer' while
  18. **                                   searching for files.
  19. **                                   (Not Released)
  20. **                2.04 : (19.07.96) Finder's window will now open on
  21. **                                   the default public screen, not
  22. **                                   on Workbench. (Workbench is
  23. **                                   usually the default public
  24. **                                   screen, but not always).
  25. **                                  When the Zoom gadget is used, the
  26. **                                   ListView no longer forgets what it
  27. **                                   was displaying.
  28. **                                  Major bug fix - In previous
  29. **                                   versions, the Listview would
  30. **                                   'forget' any filenames which left
  31. **                                   the current view.
  32. **                                  Source cleaned up a bit. Some of
  33. **                                   functions generated by GadToolsBox
  34. **                                   which have to be modified have been
  35. **                                   moved from "Finder_GUI.c" to 
  36. **                                   "Finder.c". This makes redesigning
  37. **                                   the GUI easier as the file needs
  38. **                                   less editing.
  39. **                                   NOTE: See "Finder_GUI.c" for the
  40. **                                          Instructions on the changes
  41. **                                          necessary.
  42. **                                   (Not Released)
  43. **                2.05 : (27.07.96) MAJOR bug fix. The IDCMP handler has
  44. **                                   been altered so that is uses no CPU
  45. **                                   time at all instead of (as was the
  46. **                                   case in earlier versions) swallowing
  47. **                                   all spare CPU time and thereby
  48. **                                   causing slow down on everything else.
  49. **                                  Totally new error handling system.
  50. **                                   Up until now I never tested Finder
  51. **                                   in any situation which might cause
  52. **                                   it to fail. When I did, I noticed
  53. **                                   that the error handling system was
  54. **                                   massively flawed. I was using the
  55. **                                   function "sprintf" which copies text
  56. **                                   to a variable, but I was passing it
  57. **                                   a file pointer (stderr). If any of
  58. **                                   the error messages were called this
  59. **                                   caused a crash (e.g. If it is run on
  60. **                                   <OS3.0). Now, Finder opens a small
  61. **                                   CON: window as soon as any faults
  62. **                                   appear and leaves the window until
  63. **                                   the user closes it. It also gives
  64. **                                   a rough idea of a possible solution
  65. **                                   to the problem.
  66. **                                  Changed the ListView from being Read-
  67. **                                   Only to the Show Selected option.
  68. **                                   This has no effect on the operation
  69. **                                   of Finder, but it does mean that
  70. **                                   when you are trying to remember the
  71. **                                   name/path of a file in the display
  72. **                                   while scrolling around, you can mark
  73. **                                   it by clicking on it and it will
  74. **                                   change colour to blue and remain so.
  75. **                                   (I only added this as I thought it
  76. **                                   might be useful).
  77. **                                   (Public Release #2 - Aminet)
  78. **                2.06 : (04.10.96) Nothing particularly new, just added
  79. **                                   the checking for a keyfile. However,
  80. **                                   the program IS NOT shareware, the
  81. **                                   keys are available freely from me.
  82. **                                   This is simply a way of keeping track
  83. **                                   of how many people (if any!) use
  84. **                                   Finder and if it is worth me 
  85. **                                   continuing development. If you use it
  86. **                                   PLEASE register it. IT IS FREE!!!
  87. **                                  Ooops! Just noticed another silly bug!
  88. **                                   If your started Finder via wb, it would
  89. **                                   open the libraries twice (silly me!)
  90. **                                   I only spotted this because the
  91. **                                   registration req. is in the library
  92. **                                   opening routine, so it popped up twice!
  93. **                                   This has now been removed!
  94. **                2.07 : (29.10.96) Due to a good response to the registration
  95. **                                   (thanks - you know who you are) I have
  96. **                                   changed the about requester so it shows
  97. **                                   who the program is registered to.
  98. **                3.00r1 : (24.03.97) Still in heavy development. This is an
  99. **                                   internal, un-finished release. Do not
  100. **                                   distribute this version.
  101. **                                  The major addition to this release is the
  102. **                                   use of MUI for the GUI.
  103. **                                  Basic GUI layout has stayed the same, but
  104. **                                   with a few minor additions like an
  105. **                                   ASL requester available for the drawer
  106. **                                   option.
  107. **                                  DICE re-compiling support removed (MUI problems).
  108. **                3.00r2 : (22.06.97) Total re-write of ALL code.
  109. **                                   I got very annoyed with the way 3.00r1 was
  110. **                                   working out, the code never reall worked
  111. **                                   properly. I know where the problem is;
  112. **                                   The string gadgets like their contents to
  113. **                                   be stored in "char *<variable>" form. The
  114. **                                   function to setup for the search
  115. **                                   (ParsePatternNoCase) needs it's input to be
  116. **                                   an STRPTR which is an unsigned char thingy.
  117. **                                   Basically, as yet, I have been unsuccessful
  118. **                                   in getting these two to tango.
  119. **                                  I have decided to re-write the entire
  120. **                                   program in an attempt to find alternate
  121. **                                   ways around the problem. I hope that this
  122. **                                   will be the very last major revision of Finder.
  123. **                                  This is also a good excuse for me to play
  124. **                                   around with some of MUI's neat features.
  125. **                                   Because of this, I have added:
  126. **                                     Cute little Finder logo in the About
  127. **                                        requester.
  128. **                                     Improvements in the Iconification code
  129. **                                     Drag&Drop!!!! Hurrah, the wonder marvel
  130. **                                        of the 90's MUI. You can now use this
  131. **                                        fantastic invention to drag drawers onto
  132. **                                        the drawer string (and iconified AppIcon).
  133. **                                        Also, if you drag a file, it will be stripped
  134. **                                        so that the drawer it is in is put in the
  135. **                                        string object.
  136. **                                     You can now choose if you want the search to
  137. **                                      be case sensitive or not and recursive or not.
  138. **                                  Gimmicks still to add:
  139. **                                     Finder Icon as the AppIcon
  140. **                                     Abort for the search (useful on CDs!)
  141. **                                        It is possible to abort a search by sending
  142. **                                        Finder a Ctrl-C, but it can't be directed at
  143. **                                        the window, it must be sent directly to the
  144. **                                        process. This is no problem if Finder is run
  145. **                                        from CLI, but causes difficulties if it was
  146. **                                        run from Wb as you will need an external program
  147. **                                        to send the abort signal (eg 'Commander', part of
  148. **                                        the excellent Executive system).
  149. **
  150. **                                  Update: Wow! I have done it, Finder works!
  151. **                                   I really am quite surprised. It just started working
  152. **                                   when I used a pointer to an array. My thanks to Dave
  153. **                                   Michael for 'poking' me into looking at this problem.
  154. **                                  Even more surprising is that the list saving code worked
  155. **                                   basically first time with no major problems :)
  156. **                                   (I must be getting better at this! )
  157. **                                  Update2: Wow again! I have done the case sensitivity/
  158. **                                   recursion code with no problems too!
  159. **                                   All that is left is the abort stuff (DOH!)
  160. **
  161. ** To compile, type "sc FinderV3.c" at a command line.
  162. ** You would be well advised to turn on the stack check/stack extend options
  163. **  in ENV:SCOptions, without this, Finder will crash on long searches. The reason
  164. **  is that the SearchDir function is able to calll itself. Therefore, for a search
  165. **  with lots of sub-dirs, you will have MASSIVE recursion of this function. That eats
  166. **  into the stack. I am looking into a workround for this, as I intend to use some
  167. **  hooks in Finder soon which means I will have to remove the stack extend option as
  168. **  it confuses hooks quite a lot (to the extent that they stop working!).
  169. ** Finder V3 is not finished yet, it still has a way to go on the object orientation front
  170. **  (in that it still uses Return_IDs which are a bad thing. I just need a bit more time to
  171. **  get to grips with hooks). This move to greater object orientation will also allow an
  172. **  easier implementation of the search abort.
  173. **
  174. ** VERY IMPORTANT: If you are using MUIBuilder and wish to alter the
  175. **  GUI and re-generate it's source code....DONT! I have had to change the
  176. **  original GenCodeC quite a bit as it does have some holes. Sorry!
  177. **  If anyone wants info about how to re-compile, just e-mail me.
  178. **
  179. ** There are a very large number of changes from the original MUIBuilder source
  180. **  (mostly involved with the object/class names and the helpnodes).
  181. **
  182. ** Wherever possible, I have put comments in the source so it
  183. ** should be fairly easy to follow.
  184. **
  185. ** My very largest thanks _MUST_ go to Toby Simpson who wrote the
  186. ** C Tutorial that this is based on. He is entirely responsible
  187. ** for my desire to program. I saw the first 'episode' of his
  188. ** tutorial and knew I had bought 'Complete Amiga C' (by Cliff
  189. ** Ramshaw) for a good reason. After many months playing with the
  190. ** very excellent 'GadToolsBox' (nice one Jan) with not a ROM
  191. ** Kernel manual in sight (not easy!) my Finder was born.
  192. ** Without Toby, this would be a program which did nothing except
  193. ** appear in the 'Tools' menu and read ToolTypes (not very useful)!
  194. **
  195. ** However, that doesn't change the fact that Toby's version of Finder
  196. ** was seriously flawed. It handles memory VERY badly, the GUI sucks
  197. ** and I didn't write it ;)
  198. **
  199. ** I would also like to thank my C programming lecturer, Dr. David
  200. ** Hamill who has cleaned up sections of this code with stunning
  201. ** speed (well, he should be good to be a lecturer!)
  202. **
  203. **                                                       Chris.
  204. */
  205.  
  206. #include "FinderV3Main.c"
  207.